home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1998 May / Macworld (1998-05).dmg / Shareware World / Utilities / User Interface / CMScript 1.0.6 / ReadMe
Encoding:
Text File  |  1998-03-08  |  8.6 KB  |  158 lines  |  [TEXT/ttxt]

  1. CMScript
  2. © Michael Schürig 1998
  3.  
  4.  
  5. CMScript is a Contextual Menu Plugin that runs AppleScripts on the "context".
  6.  
  7. CMScript is not going to be a separate product until the end of time. Plans are that it will be integrated with a future version of Leonard Rosenthol's "OSA Menu" (see <http://www.lazerware.com/~leonardr/>).
  8.  
  9.  
  10. Installation
  11.  
  12. Put the two plugins, CMScript and ContextGrabber, and the "Contextual Menu Scripts" folder into the "Contextual Menu Items" folder inside the System Folder.
  13.  
  14.  
  15. What it does
  16.  
  17. What does it do with the scripts in the "Contextual Menu Scripts" folder? 
  18. Wherever you are CMScript takes into account scripts found in two subfolders: "Universal Scripts" and "Application Name Scripts" (e.g. "Finder Scripts", "Internet Explorer 4.0 Scripts").
  19.  
  20. BTW, you can nest folders inside the script folders. The depth is arbitrarily restricted to three levels. Also you can use aliases to scripts instead of actual scripts.
  21.  
  22. When you activate the Contextual Menu  by holding down the control key and clicking the mouse CMScript scans these folders for scripts. For each found script it checks if it applies to the context.
  23.  
  24.  
  25. How it works (technically — skip if you like)
  26.  
  27. To facilitate finding out if a script applies to the context scripts must tell what kind of data they understand: the first line (or rather paragraph as it might be wrapped) of the script's description is used for this purpose. Put the type code of the data your script can operate on there. CMScript determines if the context can be made into the desired data type or a list of items of that type. For some types you can specify even more:
  28.  
  29. fss TEXTttxt    - only SimpleText text documents
  30. fss TEXT        - any text document
  31. fss ****ttxt    - any SimpleText document
  32.  
  33. reco            - any record
  34. recopnme        - a record containing a name (= «class pnam») property and possibly others.
  35. recopnamldt     - ditto + a date (= «class ldt ») property.
  36.  
  37. You can check for "object specifiers" (sorry for the jargon):
  38.  
  39. obj cfol        - folders (only in the Finder)
  40.  
  41. And finally, of course, you can check for any old type, say text:
  42.  
  43. TEXT            - anything that can be made into text
  44. TEXT!           - only text
  45.  
  46. If a script is applicable to the context its filename is put into the CM. When a script is chosen from the CM its "open"-handler gets called with the context data as a list (possibly having only one element) of items of the desired type.
  47.  
  48.  
  49. How do I find out what the context is?
  50.  
  51. Now, the description above may have been just a bit too technical. Here's the easy way. :-)
  52.  
  53. Use the included "ContextGrabber" Module to find out about the context:
  54.  
  55. If caps lock is pressed during a context-click ContextGrabber does several things:
  56.  
  57. • It adds a menu item "Make Template Script". This command puts a script file on your desktop that's already preconfigured somewhat to be useful in the currently selected context. Remember to save it as a compiled script if you want to use it from the CMScript!
  58.  
  59. • It adds an item to "Copy Context to Clipboard" with the submenu items "Easy" and "Advanced".
  60.  
  61. "Advanced" is only suited for hardcore AppleEvent freaks, they'll get output from AEPrint (and understand what this means for them). 
  62.  
  63. "Easy" is something suitable for use as a desired context (first line of the script's description) in your own scripts. One special case is that this plugin does not take file objects to be objects, i.e. "obj file", but treats them as file specifications. Thus you'd get the more helpful "fss TEXTttxt" if you selected a SimpleText text document.
  64.  
  65.  
  66. Changing the order of scripts in the menu
  67.  
  68. You can determine the order of scripts in the contextual menu by following these conventions:
  69.  
  70. Generally scripts are alphabetically ordered, but if a script's or a folder's name starts with "xx)" (where "x" can anything except "(") this prefix is not shown in the menu.
  71.  
  72. Nested script folders whose names end with "-!!X" are ignored.
  73.  
  74. Files or folders whose name ends with "-***" generate a separator line in the context menu. CMScript tries to be smart about separators and avoids to add multiple adjacent ones. (By convention it is not possible to add a separator as the last item. Basically a plugin is allowed to separate itself from what comes before it, but not from what comes after it.) 
  75.  
  76.  
  77. Questions & Answers
  78.  
  79. Q. Why don't the installed plugins show up in the Contextual Menu?
  80. A: The most common reason is that you tried to be smart some time before and disabled "SOMobjects™ for Mac OS". Don't do that! Contextual Menu Plugins don't work without it. And beside that it does nothing bad to your system: It is a so-called shared library that does absolutely nothing unless used by an application, extension, or plugin.
  81.  
  82.  
  83. Q: Why do I see the Contextual Menu only in the Finder?
  84. A: Well, the reason is that only very few applications actually support the Contextual Menu yet. But you can get around this by installing "Apple Data Detectors" (look for it on <http://applescript.apple.com>). Among other things this will give you the "Contextual Menu Enabler" extension that will enable the contextual menu in virtually any application.
  85.  
  86. A Note of Caution: If you use "Contextual Menu Enabler" 1.0.2 (retracted by Apple!) you'll find that it adds a menu item "Turn on Contextual Menus in app name " to the Help menu of some applications. These are applications that don't support the CM directly. If you turn on the CM in such an app be sure to quit and relaunch it before using the CM for the first time. This is not strictly necessary, but may avoid trouble in some cases.
  87.  
  88.  
  89. Q: My script doesn't work. How do I find out what's happening?
  90. A: The easiest way is to run the script inside your Script Editor.
  91.  
  92. Add the following lines to your script. Of course you need to replace "Finder" with the name of the application where you intend to use the script.
  93.  
  94. tell application "Finder" to set sel to the selection
  95. open (sel)
  96.  
  97. From the "Controls" menu choose "Open Event Log" and enable both "Show Events" and "Show Event Results". This will give you a detailed log of what's happening in the script.
  98.  
  99. Unfortunately this method won't work with applications that do not have reasonable scripting support. And there may be cases where you have to test your script under the actual conditions of its use. But there's still hope:
  100.  
  101. Use the "Message Window" application to display information about your script's progress. (see <http://T3.acmetech.com/acme/files/freebies/MessageWin.hqx>)
  102.  
  103. Use the "show variables" command from the "programmer's tool" Scripting Addition to display the value of a variable in a dialog box. (see <http://www.scriptweb.com/osaxen/programmers_tool.html>)
  104.  
  105.  
  106. Q: How do I find the actual class of the object(s) that was clicked?
  107. A: Given that the application your context script is working in supports AppleScript sensibly do it like this:
  108.  
  109. on open
  110.        tell application "Finder"
  111.               set theSelection to the selection
  112.               try
  113.                      repeat with theItem in theSelection
  114.                             -- put your script here
  115.                      end repeat
  116.               on error errMsg
  117.                      display dialog errMsg buttons {"OK"} default button 1
  118.               end try
  119.        end tell
  120. end open
  121.  
  122.  
  123. In case of trouble
  124.  
  125. • Make sure only one "Contextual Menu Extension" is installed. This can be a problem in particular on non-US systems as some software installers may install a duplicate US-copy on such a system (a case in point apparently is/was "Apple Data Detectors").
  126.  
  127. Please tell me about your problems so I can do something about them or add them here.
  128.  
  129.  
  130. If you've written a cool script…
  131.  
  132. …please send me a copy. I'll consider it for inclusion with a future version of CMScript or maybe a separate "Service Pack".
  133.  
  134.  
  135. Version History
  136.  
  137. The current version is always available from my home page (see below). Also, I'll submit new versions to the info-mac archive.
  138.  
  139. 1.0.6  Improved ordering of scripts.
  140. 1.0.5  'obj ' context are now recognized correctly. (Thanks to Jens Miltner.)
  141.           Slight twiddling of memory handling.
  142. 1.0.4  Fixed a hierarchical menu handling bug. (Thanks to Lindsey Dubb for spotting it.)
  143. 1.0.3  Added "!" to specify strict checking for arbitrary types.
  144. 1.0.2  Added special treatment of record specifiers in context description.
  145. 1.0.1  First public version.
  146. 1.0     Not released.
  147.  
  148.  
  149. Disclaimer
  150.  
  151. You might have guessed it already, but I take no responsibility for the consequences of anything CMScript does to your computer. If you think this is unacceptable, just don't use it.
  152.  
  153.  
  154. That's it for now. I appreciate any bug reports and suggestions. Have as much fun with this thingie as possible.
  155.  
  156. Michael Schürig
  157. <mailto:schuerig@acm.org?Subject=[CMScript]>
  158. <http://www.uni-bonn.de/~uzs90z/>